function type1change(id,type1,type2) {
	var checkvalue = $("#type1_"+id).val();
	$.ajax({
		type : "get",
		url : BASE_URL+'/main/product_getType.action?parent='+checkvalue,
		dataType : "json",
		success : function(content) {
			var list = content;
			var op = "";
			for (var i in list) {
				var checkd = "";
				if (type2!=null&&type2==list[i].id) {
					checkd = " selected=\"selected\" ";
				}
				var tmp = "<option value='" + list[i].id + "'"+checkd+">" + list[i].name + "</option>";
				op = op + tmp;
			}
			$("#type2_"+id).html(op);
			var type2checkd = $("#type2_"+id).val();
			if (checkvalue==type1&&type2checkd==type2) {
				$("#a_"+id).hide();
			} else {
				$("#a_"+id).show();
			}
		}
	});
}

function type2change(id,type2) {
	var type2checkd = $("#type2_"+id).val();
	if (type2checkd==type2) {
		$("#a_"+id).hide();
	} else {
		$("#a_"+id).show();
	}
}

function updatep(id) {
	var type1 = $("#type1_"+id).val();
	var type2 = $("#type2_"+id).val();
	$.ajax({
		type : "get",
		url : BASE_URL+'/main/product_updatePType.action?id='+id+'&type1='+type1+'&type2='+type2,
		dataType : "json",
		success : function(content) {
			var list = content;
			if('true'==list[0].result) {
				alert("更新成功！");
				$("#a_"+id).hide();
				$("#tr_"+id).attr("style","");
				$("#type1_"+id).attr("onchange","type1change("+id+","+type1+","+type2+");");
				$("#type2_"+id).attr("onchange","type2change("+id+","+type2+");");
			} else {
				alert("更新失败！");
			}
		}
	});
}
